package com.example.unisys.service;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.unisys.entity.SchoolNo;
import com.example.unisys.dao.SchoolNoMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class SchoolNoService extends ServiceImpl<SchoolNoMapper,SchoolNo> {


    public Integer insert(SchoolNo sn){
        return baseMapper.insert(sn);
    }

    public String getById(int school_no){
        return baseMapper.getById(school_no);
    }

    public HashMap<String,String> getAll(){
        List<SchoolNo> ls=baseMapper.getAll();
        HashMap<String,String> hs = new HashMap<>();
        for(SchoolNo sn:ls)
            hs.put(sn.getSchool_no(),sn.getSchool_name());
        return hs;
    }

}
